//
//  JwHttpManager.h
//  JwPack
//
//  Created by 陈警卫 on 2024-08-29.
//

#import <Foundation/Foundation.h>
#import <AFNetworking/AFNetworking.h>

#import "JwHttpConfig.h"
#import "JwHttpHandel.h"
#import "JwHttpBaser.h"

#define kJwHttpManager [JwHttpManager shared]

NS_ASSUME_NONNULL_BEGIN

@interface JwHttpManager : NSObject

@property (nonatomic, strong) NSCondition *condition;
@property (nonatomic, assign) BOOL lock;

/// 单例
+ (JwHttpManager *)shared;

@property (nonatomic, strong) AFHTTPSessionManager *httpSession;

@property (nonatomic, strong) NSString *fileCompleFolderPath;

/// 默认路径
@property (nonatomic, strong) NSString *baseUrl;
/// 默认节点
@property (nonatomic, strong) NSString *basePoint;

/// 指定数据处理(默认 JwHttpHandel)
@property (nonatomic, strong) Class<JwHttpHandelDelegate> handleClass;
/// 指定参数处理(默认 JwHttpBaser)
@property (nonatomic, strong) Class<JwHttpBaserDelegate> baserClass;


/// 请求
- (void)requestWithConfig:(JwHttpConfig *)config comple:(void (^)(JwHttpConfig *config))comple;

/// 请求
- (JwHttpConfig *)request:(kJwHttpMethod *)method
                      url:(nullable NSString *)url
                    point:(nullable NSString *)point
                   params:(nullable NSDictionary *)params
                  headers:(nullable NSDictionary *)headers
                   owners:(nullable NSDictionary *)owners
                   comple:(void (^)(JwHttpConfig * config))comple;

/// 请求
- (JwHttpConfig *)request:(kJwHttpMethod *)method
                    point:(nullable NSString *)point
                   params:(nullable NSDictionary *)params
                  headers:(nullable NSDictionary *)headers
                   owners:(nullable NSDictionary *)owners
                   comple:(void (^)(JwHttpConfig * config))comple;

/// 请求(异步带锁)
- (void)requestLockWithConfig:(JwHttpConfig *)config comple:(void (^)(JwHttpConfig *config))comple;

/// 请求(异步带锁)
- (JwHttpConfig *)requestLock:(kJwHttpMethod *)method
                          url:(nullable NSString *)url
                        point:(nullable NSString *)point
                       params:(nullable NSDictionary *)params
                      headers:(nullable NSDictionary *)headers
                       owners:(nullable NSDictionary *)owners
                       comple:(void (^)(JwHttpConfig * config))comple;

/// 请求(异步带锁)
- (JwHttpConfig *)requestLock:(kJwHttpMethod *)method
                        point:(nullable NSString *)point
                       params:(nullable NSDictionary *)params
                      headers:(nullable NSDictionary *)headers
                       owners:(nullable NSDictionary *)owners
                       comple:(void (^)(JwHttpConfig * config))comple;

/// 请求(异步带锁及逻辑处理)
- (void)requestHandelWithConfig:(JwHttpConfig *)config comple:(void (^)(JwHttpConfig * config))comple;


/// 请求(异步带锁及逻辑处理)
- (JwHttpConfig *)requestHandel:(kJwHttpMethod *)method
                            url:(nullable NSString *)url
                          point:(nullable NSString *)point
                         params:(nullable NSDictionary *)params
                        headers:(nullable NSDictionary *)headers
                         owners:(nullable NSDictionary *)owners
                decodeModelName:(nullable NSString *)decodeModelName
                     decodePath:(nullable NSString *)decodePath
                         comple:(void (^)(JwHttpConfig * config))comple;

/// 请求(异步带锁及逻辑处理)
- (JwHttpConfig *)requestHandel:(kJwHttpMethod *)method
                          point:(nullable NSString *)point
                         params:(nullable NSDictionary *)params
                        headers:(nullable NSDictionary *)headers
                         owners:(nullable NSDictionary *)owners
                decodeModelName:(nullable NSString *)decodeModelName
                     decodePath:(nullable NSString *)decodePath
                         comple:(void (^)(JwHttpConfig * config))comple;


@end

NS_ASSUME_NONNULL_END
